package com.deng.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.deng.entity.Usermessage;
import com.deng.mapper.UsermessageMapper;
import com.deng.service.UsermessageService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dengwenxiong
 * @since 2021-05-05
 */
@Service
public class UsermessageServiceImpl extends ServiceImpl<UsermessageMapper, Usermessage> implements UsermessageService {
    @Autowired
    UsermessageMapper usermessageMapper;

    @Override
    public IPage paging(Page page, QueryWrapper<Usermessage> wrapper) {

        return usermessageMapper.selectMessages(page,wrapper);
    }

    @Override
    public void updateToReader(List<Long> ids) {
        if(ids.isEmpty()) return;
        usermessageMapper.updateToReaded(new QueryWrapper<Usermessage>()
                .in("id", ids)
        );

    }
}
